From a1041848b5eba0726c9c7fd59cec56301769e8a4 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Sun, 27 Aug 2006 06:56:01 +0100 Subject: [PATCH] [PATCH] fix null pointer dereference in xen_guest_lookup() The latest ELF changes have a null pointer dereference bug when you have neither an elf notes section nor a __xen_guest_string. This patch checks for the existence of the __xen_guest_string prior to using it. Please apply. Thanks, Alex Signed-off-by: Alex Williamson --- --- tools/libxc/xc_load_elf.c | 3 +++ xen/common/elf.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tools/libxc/xc_load_elf.c b/tools/libxc/xc_load_elf.c index 9964a0dbb4..3fbd3d9ccc 100644 --- a/tools/libxc/xc_load_elf.c +++ b/tools/libxc/xc_load_elf.c @@ -93,6 +93,9 @@ static const char *xen_guest_lookup(struct domain_setup_info *dsi, int type) const char *fallback; const char *p; + if ( !dsi->__xen_guest_string ) + return NULL; + if ( type > sizeof(xenguest_fallbacks) ) return NULL; diff --git a/xen/common/elf.c b/xen/common/elf.c index 594060c99b..00730c1bb8 100644 --- a/xen/common/elf.c +++ b/xen/common/elf.c @@ -49,6 +49,9 @@ static const char *xen_guest_lookup(struct domain_setup_info *dsi, int type) const char *fallback; const char *p; + if ( !dsi->__xen_guest_string ) + return NULL; + if ( type > sizeof(xenguest_fallbacks) ) return NULL; -- 2.30.2